import request from './request';
import { getRefreshToken } from './token';

export async function refreshToken() {
  console.log('刷新token');
  const resp = await request.get('/refresh_token', {
    headers: {
      Authorization: `Bearer ${getRefreshToken()}`
    },
    __isRefreshToken: true, // 添加私有属性，判断请求是否刷新token
  }) 
  return resp.code === 0;
}

// 写在一块，高内聚
export function isRefreshRequest(config) {
  return !!config.__isRefreshToken;
}